/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.workforce.common.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 *
 * @author neo
 */
public class FieldTextboxTag extends FieldBaseTag {

    protected String size;
    protected String cols;
    protected String rows;
    protected String max;
    @Override
    public int doStartTag() throws JspException {
        try {
            JspWriter out = pageContext.getOut();
            StringBuffer s = new StringBuffer();
            s.append("<textarea ");
            if (sid != null) {
                s.append("id=\"").append(sid).append("\" ");
            }
            if (name != null) {
                s.append("name=\"").append(name).append("\" ");
            }
            if (size != null) {
                s.append("size=\"").append(size).append("\" ");
            }
            if (cols != null) {
                s.append("cols=\"").append(cols).append("\" ");
            }
            if (rows != null) {
                s.append("rows=\"").append(rows).append("\" ");
            }
            if (sClass != null) {
                s.append("class=\"").append(sClass).append("\" ");
            }
            if (style != null) {
                s.append("style=\"").append(style).append("\" ");
            }
            if (readOnly != null) {
                s.append("readonly=\"").append(readOnly).append("\" ");
            }
            if (max != null) {
                s.append("maxlength=\"").append(max).append("\" ");
            }
            if( onFocus != null ) {
                s.append("onfocus=\"").append(onFocus).append("\" ");
            }
            if( onBlur != null ) {
                s.append("onblur=\"").append(onBlur).append("\" ");
            }
            s.append(">");
            s.append("</textarea>\n</td>");
            beginTag();
            out.print(s.toString());
            endTag();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return SKIP_BODY;
    }

    @Override
    protected void beginTag() {
        JspWriter out = pageContext.getOut();
        StringBuffer s = new StringBuffer();
        try {
            s.append("<table><tr><td valign=\"top\"><label>");
            if( label != null ) {
            s.append(label);
            } else {
                s.append("");
            }
            s.append("</label></td><td valign=\"top\">");
            out.print(s.toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    @Override
     protected void endTag() {
        JspWriter out = pageContext.getOut();
        StringBuffer s = new StringBuffer();
        try {
            s.append("<td valign=\"top\"><img src= \"imgs/info_16.png\" alt=\"info\" ");
            s.append("onmouseover=\"showInfo(this, event, 'info_" + sid + "')\" ></td><td>");
            s.append("<div id=\"info_" + sid + "\" ");
            if (styleTooltip == null) {
                s.append("class=\"styleTooltip_default\">");
            } else {
                s.append("class=\"");
                s.append(styleTooltip);
                s.append("\">");
            }
            if( tooltipText != null ) {
            s.append(tooltipText);
            } else {
                s.append("Description for "+ sid + ".");
            }
            s.append("</div></td></tr></table>");
            out.print(s.toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }


    public void setSize(String size) {
        this.size = size;
    }

    public void setCols(String cols) {
        this.cols = cols;
    }

    public void setRows(String rows) {
        this.rows = rows;
    }

    public void setMax(String max) {
        this.max = max;
    }
    
    
}
